//
//  FollowInCell.m
//  Estate
//
//  Created by heyong on 16/6/21.
//  Copyright © 2016年 ttsx. All rights reserved.
//

#import "FollowInCell.h"

@implementation FollowInCell
- (UIButton *)btn{
    if(_btn==nil){
        _btn = [UIButton buttonWithType:UIButtonTypeCustom];
        self.timeBtn = _btn;
        [_btn setUserInteractionEnabled:NO];
        UIImage *image = [[UIImage imageNamed:@"dubanditu"] stretchableImageWithLeftCapWidth:10 topCapHeight:10];
        [_btn setBackgroundImage:image forState:UIControlStateNormal];
        [_btn setTitleColor:[UIColor colorWithRed:0.99 green:0.98 blue:0.98 alpha:1.00] forState:UIControlStateNormal];
        _btn.titleLabel.font = [UIFont systemFontOfSize:14.0];
        
    }
    return _btn;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    self.selectionStyle=UITableViewCellSelectionStyleNone;
    [self.contentView addSubview:self.btn];
}

- (void)setTitle:(NSString *)titleStr andDeTime:(NSString *)deTimeStr andTime:(NSString *)timeStr andState:(int)state andProcessType:(int)type {
    [self.btn setTitle:timeStr forState:UIControlStateNormal];

    CGSize titleSize = [timeStr sizeWithAttributes:@{NSFontAttributeName: [UIFont fontWithName:self.btn.titleLabel.font.fontName size:self.btn.titleLabel.font.pointSize]}];
    titleSize.height = 20;
    titleSize.width += 20;
    CGFloat h= self.frame.size.height;
    self.btn.frame = CGRectMake(0, (h-40*BIZ)/2, titleSize.width, 40*BIZ);
 
    self.title.text=titleStr;
    self.title.textColor=[UIColor colorWithRed:0.40 green:0.41 blue:0.42 alpha:1.00];
    self.deTime.text = deTimeStr;
    self.deTime.textColor=[UIColor colorWithRed:0.42 green:0.43 blue:0.43 alpha:1.00];
    self.state.textColor=[UIColor colorWithRed:0.18 green:0.64 blue:0.59 alpha:1.00];
    
//    if (type == PROCESS_TYPE_SUPERVISE) { //督办单
//        if (state == PROCESS_STAGE_START || state == PROCESS_STAGE_DOING || state == PROCESS_STAGE_CHECK_PASS_YES_NO) {
//            self.state.text = @"待执行";
//        } else if (state == PROCESS_STAGE_CHECK) {
//            self.state.text = @"待复查";
//        } else if (state == PROCESS_STAGE_END || state == PROCESS_STAGE_CHECK_PASS_YES) {
//            self.state.text = @"结束";
//        }
//    } else if (type == PROCESS_TYPE_FOLLOW) { //跟进单
//        if (state == PROCESS_STAGE_REVIEW || state == PROCESS_STAGE_START){
//            self.state.text = @"待审阅";
//        } else if (state == PROCESS_STAGE_DOING || state == PROCESS_STAGE_REVIEW_PASS_YES || state == PROCESS_STAGE_CHECK_PASS_YES_NO) {
//            self.state.text = @"待执行";
//        } else if (state == PROCESS_STAGE_CHECK) {
//            self.state.text = @"待复查";
//        } else if (state == PROCESS_STAGE_REVIEW_PASS_NO) {
//            self.state.text = @"审阅不通过";
//        } else if (state == PROCESS_STAGE_END ) {
//            self.state.text = @"结束";
//        }else if(state == PROCESS_STAGE_CHECK_PASS_YES){
//             self.state.text = @"复查通过";
//        }
//    } else if (type == 100) {   // 发送形式为无的督办单
//        if (state == PROCESS_STAGE_START || state == PROCESS_STAGE_DOING || state == PROCESS_STAGE_REVIEW_PASS_NO || state == PROCESS_STAGE_CHECK){
//            self.state.text = @"待执行";
//        } else if (state == PROCESS_STAGE_REVIEW) {
//            self.state.text = @"待审阅";
//        } else if (state == PROCESS_STAGE_REVIEW_PASS_YES || state == PROCESS_STAGE_END) {
//            self.state.text = @"结束";
//        }
//    } else
    if (type == 3) { // 验收单
        if (state == PROCESS_STAGE_START || state == PROCESS_STAGE_REVIEW || state == PROCESS_STAGE_CHECK) {
            self.state.text = @"待验收";
        } else if (state== PROCESS_STAGE_CHECK_PASS_YES_NO ||state == PROCESS_STAGE_DOING || state == PROCESS_STAGE_REVIEW_PASS_NO) {
            self.state.text = @"不合格";
        } else if (state== PROCESS_STAGE_END || state== PROCESS_STAGE_CHECK_PASS_YES || state == PROCESS_STAGE_REVIEW_PASS_YES) {
            self.state.text = @"合格";
        }
    }else{
        if (state == PROCESS_STAGE_REVIEW) {
            self.state.text = @"待审阅";
        } else if (state == PROCESS_STAGE_REVIEW_PASS_NO) {
            self.state.text = @"审阅不通过";

        } else if (state == PROCESS_STAGE_CHECK) {
            self.state.text = @"待复查";

        } else if (state == PROCESS_STAGE_CHECK_PASS_YES) {
            self.state.text = @"复查通过";

        } else if (state == PROCESS_STAGE_END) {
            self.state.text = @"结束";
        } else if (state == PROCESS_STAGE_DOING) {
            self.state.text = @"待执行";
            
        }
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

@end
